﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Expect.Core.Reports
{
    /// <summary>
    /// Base class for report metadata
    /// </summary>
    public abstract class ReportMetadataBase : IEnumerable<ReportMetadataItem>
    {
        /// <summary>
        /// Initialize metadata items
        /// </summary>
        public abstract void Initialize();

        /// <summary>
        /// item indexer
        /// </summary>
        /// <param name="idx"></param>
        /// <returns></returns>
        public ReportMetadataItem this[int idx]
        {
            get
            {
                return _items[idx];
            }
        }

        private List<ReportMetadataItem> _items = new List<ReportMetadataItem>();

        /// <summary>
        /// Add file to metadata
        /// </summary>
        /// <param name="name"></param>
        public void AddFile(string name)
        {
            _items.Add(new ReportMetadataItem{Kind = ReportItemKind.File, Name = name});
        }

        /// <summary>
        /// Add folder to metadata
        /// </summary>
        /// <param name="name"></param>
        public void AddFolder(string name)
        {
            _items.Add(new ReportMetadataItem { Kind = ReportItemKind.Folder, Name = name });
        }

        /// <summary>
        /// Get the number of items in metadata
        /// </summary>
        public int Count
        {
            get
            {
                return _items.Count;
            }
        }

        /// <summary>
        /// Returns an enumerator that iterates through the collection.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection.
        /// </returns>
        /// <filterpriority>1</filterpriority>
        public IEnumerator<ReportMetadataItem> GetEnumerator()
        {
            return _items.GetEnumerator();
        }

        /// <summary>
        /// Returns an enumerator that iterates through a collection.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _items.GetEnumerator();
        }
    }

    internal class InternalReportMetadata : ReportMetadataBase
    {
        public override void Initialize()
        {            
        }
    }
}
